/*
 * @Author: szx
 * @Date: 2021-11-01 11:26:17
 * @LastEditTime: 2021-11-01 11:40:08
 * @Description:
 * @FilePath: \leetcode\300-399\387\387.cpp
 */
#include <iostream>
#include <unordered_set>
using namespace std;
class Solution {
   public:
    int firstUniqChar(string s) {
        int arr[26]{0};
        int n = s.length();
        for (int i = 0; i < n; i++) {
            arr[s[i] - 'a']++;
        }
        for (int i = 0; i < n; i++) {
            if (arr[s[i] - 'a'] == 1) {
                return i;
            }
        }
        return -1;
    }
};

int main() {
    Solution s;
    cout << s.firstUniqChar("leetcode") << endl;
    return 0;
}